<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('自主投放列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="formId">
				<div class="select-list">
					<ul>
						<li>
							用户姓名：<input type="text" name="name"/>
						</li>
						<li>
							手机号：<input type="text" name="phone"/>
						</li>
						<li>
							分拣员姓名：<input type="text" name="cmName"/>
						</li>
						<li>
							街道：
							<select  id="street"  name="street" th:with="address=${@address.selectAllstreet()}">
								<option selected="selected" disabled="disabled"  style='display: none' value=''></option>
								<option th:each="address : ${address}" th:text="${address.street}" th:value="${address.street}"></option>
							</select>
						</li>
						<li>
							社区：
							<select id="community" name="community" th:with="address=${@address.selectAllcommunity()}">
								<option selected="selected" disabled="disabled"  style='display: none' value=''></option>
								<option th:each="address : ${address}" th:text="${address.community}" th:value="${address.community}"></option>
							</select>
						</li>
						<li>
							小区：
							<select id="village"  name="village" th:with="address=${@address.selectAllvillage()}">
								<option selected="selected" disabled="disabled"  style='display: none' value=''></option>
								<option th:each="address : ${address}" th:text="${address.village}" th:value="${address.village}"></option>
							</select>
						</li>
						<li>
							订单状态：
							<select name="status" th:with="type=${@dict.getType('sys_record_status')}">
								<option value="">全部</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
						</li>
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="btn-group-sm" id="toolbar" role="group">
		</div>
		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
	</div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
	var editFlag = [[${@permission.hasPermi('system:trashRecord:edit')}]];
	var removeFlag = [[${@permission.hasPermi('system:trashRecord:remove')}]];
	var prefix = ctx + "system/trashAutonomousRecord";
	var prefix1 = ctx + "system/trashAutonomousRecordDetails";
	var datas = [[${@dict.getType('sys_autonomous_status')}]];
	$(function() {
		var options = {
			url: prefix + "/list",
			createUrl: prefix + "/add",
			updateUrl: prefix + "/edit/{id}",
			removeUrl: prefix + "/remove",
			exportUrl: prefix + "/export",
			modalName: "自主投放记录",
			showExport: true,
			columns: [{
				checkbox: true
			},
				{
					field : 'id',
					title : '',
					visible: false
				},
				{
					field : 'wxUserId',
					title : '',
					visible: false
				},
				{
					field : 'name',
					title : '姓名',
					sortable: true
				},
				{
					field : 'phone',
					title : '手机号',
					sortable: true
				},
				{
					field : 'address',
					title : '地址',
					sortable: true
				},
				{
					field : 'cmName',
					title : '回收员',
					sortable: true
				},
				{
					field : 'status',
					title : '订单状态',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(datas, value);
					}
				},
				{
					field : 'successTime',
					title : '回收时间',
					sortable: true
				},
				{
					title: '操作',
					align: 'center',
					formatter: function(value, row, index) {
						var actions = [];
						actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)"onclick="opendetailed( \'' + row.id + '\') "><i class="fa fa-flag"></i>查看</a> ');
						return actions.join('');
					}
				}]
		};
		$.table.init(options);
	});


	$("#street").change(function(){
		debugger
		var name = $("#street").val();
		if(name ==''){
			return;
		}
		$.ajax({
			url:'/system/address/selectCommunityBystree?name='+name,
			async:false,
			type:'get',
			success:function(data){
				var t3 = $("#community").empty();
				var t4 = $("#village").empty();
				t3.append("<option selected=\"selected\" disabled=\"disabled\"  style='display: none' value=''></option>");
				t4.append("<option selected=\"selected\" disabled=\"disabled\"  style='display: none' value=''></option>");
				for ( var i = 0; i < data.length; i++) {
					t3.append("<option value='"+data[i].community+"'>"+ data[i].community+"</option>");
					t4.append("<option value='"+data[i].village+"'>"+ data[i].village+"</option>");
				}
			}
		})
	});

	$("#community").change(function(){
		var name = $("#community").val();
		if(name ==''){
			return;
		}
		$.ajax({
			url:'/system/address/selectVillageBycommunity?name='+name,
			async:false,
			type:'get',
			success:function(data){
				debugger
				var t3 = $("#village").empty();
				t3.append("<option selected=\"selected\" disabled=\"disabled\"  style='display: none' value=''></option>");
				for ( var i = 0; i < data.length; i++) {
					t3.append("<option value='"+data[i].village+"'>"+ data[i].village+"</option>");
				}
				$("#street").val(data[0].street)
			}
		})
	});


	$("#village").change(function(){
		var name = $("#village").val();
		if(name ==''){
			return;
		}
		$.ajax({
			url:'/system/address/listByVillage',
			async:false,
			type:'post',
			data:{village:name},
			success:function(data){
				$("#street").val(data[0].street)
				$("#community").val(data[0].community)
			}
		})
	});通过调用$.modal.open()


	function opendetailed(id) {
		$.modal.open2("自主投放详情列表", prefix1 + "?taRecordId="+id);
	}
</script>
</body>
</html>